package com.sms.api.web;

import com.sms.api.bean.ApiResult;
import com.sms.api.service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;

/**
 * 短信发送
 * 2021.01.15
 */
@Controller
@RequestMapping("/sms")
public class SmsController {
	/**
	 * 获取远程ip使用
	 */
	@Autowired
	private HttpServletRequest request;

	@Autowired
	private SmsService service;

	/**
	 * 请求验证码
	 * @param mobile
	 * @return
	 */
	@RequestMapping("/sendSms")
	@ResponseBody
	public ApiResult<String> send(@RequestParam String mobile) {
		ApiResult<String> rest= service.send(mobile,request) ;
		return rest;
	}

}
